package com.kantboot.system.user.domain.vo;

import com.kantboot.system.user.domain.entity.SysUserBalance;
import com.kantboot.system.user.domain.entity.SysUserOnline;
import com.kantboot.system.user.domain.entity.SysUserRole;
import com.kantboot.util.core.jpa.KantbootGenerationType;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.GenericGenerator;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户自己的信息展示
 */
@Entity
@Getter
@Setter
@Table(name = "sys_user")
@Accessors(chain = true)
@EntityListeners(AuditingEntityListener.class)
@DynamicUpdate
@DynamicInsert
public class SysUserOfSelfVO implements Serializable {

    /**
     * 主键
     */
    @Id
    @GenericGenerator(name = "snowflakeId",strategy = KantbootGenerationType.SNOWFLAKE)
    @GeneratedValue(generator = "snowflakeId")
    @Column(name = "id")
    private Long id;

    /**
     * 用户角色关联
     */
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private List<SysUserRole> userRoleList;

    /**
     * 用户余额关联
     */
    @OneToMany(cascade = CascadeType.ALL)
    @JoinColumn(name = "user_id", referencedColumnName = "id")
    private List<SysUserBalance> userBalance;

    /**
     * 关联在线
     */
    @OneToOne
    @JoinColumn(name = "id", referencedColumnName = "user_id")
    private SysUserOnline userOnline;

    /**
     * 是否为临时用户，是没有绑定账号的用户，
     * 比如微信登录还没有绑定用户账号，则设为临时用户
     * 当绑定后，将临时用户的数据合并到正式用户中
     */
    @Column(name = "is_temporary")
    private Boolean isTemporary;

    /**
     * 是否已初始化完成
     */
    @Column(name = "is_init")
    private Boolean isInit;

    /**
     * 用户账号
     */
    @Column(name = "username", length = 64)
    private String username;

    /**
     * 手机号
     */
    @Column(name = "phone", length = 64)
    private String phone;

    /**
     * 邮箱
     */
    @Column(name = "email")
    private String email;

    /**
     * 性别编码
     * 男：male
     * 女：female
     * 未知：unknown
     * 保密：secret
     */
    @Column(name="gender_code")
    private String genderCode;


    /**
     * 昵称
     */
    @Column(name = "nickname", length = 64)
    private String nickname;

    /**
     * 头像的文件id
     */
    @Column(name = "file_id_of_avatar")
    private Long fileIdOfAvatar;

    /**
     * 用户自我介绍
     */
    @Column(name = "introduction", length = 1024)
    private String introduction;

    /**
     * 直属码
     */
    @Column(name = "direct_code")
    private String directCode;

    /**
     * 邀请码
     */
    @Column(name = "invite_code")
    private String inviteCode;

    /**
     * 邀请人id
     */
    @Column(name = "invite_user_id")
    private Long inviteUserId;

    /**
     * 创建时间
     */
    @CreatedDate
    @Column(name = "gmt_create")
    private Date gmtCreate;

    /**
     * 修改时间
     */
    @LastModifiedDate
    @Column(name = "gmt_modified")
    private Date gmtModified;

}
